<?php

/**
 * LigneDevis form base class.
 *
 * @method LigneDevis getObject() Returns the current form's model object
 *
 * @package    SdCommerce
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseLigneDevisForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                => new sfWidgetFormInputHidden(),
      'designation'       => new sfWidgetFormInputText(),
      'taux_remise'       => new sfWidgetFormInputText(),
      'taux_tva'          => new sfWidgetFormInputText(),
      'quantite'          => new sfWidgetFormInputText(),
      'prix_unitaire_ht'  => new sfWidgetFormInputText(),
      'prix_total_ht'     => new sfWidgetFormInputText(),
      'montant_ligne_ht'  => new sfWidgetFormInputText(),
      'prix_tva'          => new sfWidgetFormInputText(),
      'prix_total_ttc'    => new sfWidgetFormInputText(),
      'stock_article_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('StockArticle'), 'add_empty' => true)),
      'id_devis'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Devis'), 'add_empty' => true)),
      'tva_id'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Tva'), 'add_empty' => true)),
      'prix_total_ttcnet' => new sfWidgetFormInputText(),
      'created_at'        => new sfWidgetFormDateTime(),
      'updated_at'        => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'designation'       => new sfValidatorString(array('max_length' => 255)),
      'taux_remise'       => new sfValidatorNumber(),
      'taux_tva'          => new sfValidatorNumber(array('required' => false)),
      'quantite'          => new sfValidatorInteger(),
      'prix_unitaire_ht'  => new sfValidatorNumber(),
      'prix_total_ht'     => new sfValidatorNumber(array('required' => false)),
      'montant_ligne_ht'  => new sfValidatorNumber(),
      'prix_tva'          => new sfValidatorNumber(),
      'prix_total_ttc'    => new sfValidatorNumber(),
      'stock_article_id'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('StockArticle'), 'required' => false)),
      'id_devis'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Devis'), 'required' => false)),
      'tva_id'            => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Tva'), 'required' => false)),
      'prix_total_ttcnet' => new sfValidatorNumber(array('required' => false)),
      'created_at'        => new sfValidatorDateTime(),
      'updated_at'        => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('ligne_devis[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'LigneDevis';
  }

}
